<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter" %>
<%@ page import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter" %>
<%@ page import="org.springframework.security.web.WebAttributes" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/common/meta.jsp" %>
	<meta content="ordernew" name="activemenu" />
	<link href="${ctx}/css/base.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/master.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/jquery.autocomplete.css" type="text/css" rel="stylesheet"/>
	<script src="${ctx}/js/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/js/table.js" type="text/javascript"></script>
	<script src="${ctx}/js/droplist.js" type="text/javascript"></script>
	<script src="${ctx}/js/jquery.autocomplete.js" type="text/javascript"></script>
	<script>
	$(document).ready(function() {
		$('#cusNameAuto').autocomplete("${ctx}/droplist!partner.action", {
			minChars: 1,
			autoFill: false,
			scrollHeight: 220,
            formatItem:function(row) { return row; },
            parse:formateData
		});
        $('#cusCodeAuto').autocomplete("${ctx}/droplist!partnercode.action", {
			minChars: 2,
			autoFill: false,
			scrollHeight: 220,
            formatItem:function(row) { return row; },
            parse:formateData
		});

        $('#cusNameAuto').result(function(event,name,id){
            var end = name.indexOf(')') ;
            var code = name.substr(1,end-1);
             $(this).val(name.substr(end+1)) ;
            $('#cusId').val(id);
            $('#cusCodeAuto').val(code);
        });
        $('#cusCodeAuto').result(function(event,name,id){
            var end = name.indexOf(')') ;
            var code = name.substr(1,end-1);
             $('#cusNameAuto').val(name.substr(end+1)) ;
            $('#cusId').val(id);
            $('#cusCodeAuto').val(code);
        });

        init();
    });

    function formateData(json){
        var parsed = [];
		var data = eval(json );
		for(var item in data){	
			var line = data[item];	
			var p = {data: '('+line.code+')'+line.name,
					value: line.id,
					result: ""}
            parsed[parsed.length] = p;
		}
        return parsed;
	}

	function reloadSon(id,value){
		var droplist = $('#'+id);
		var action = droplist.attr('action');
		action += '?id=' + value;
		initList(droplist,action);
		$('#orderFields').find('.optionField').hide();
		$('#orderFields').find('.type' + value).show();
	}
    function init(){
        var value = $('#biz_type').attr('init');
        $('#orderFields').find('.optionField').hide();
		$('#orderFields').find('.type' + value).show();
    }
    </script>
</head>
<body>
<jsp:include page="/common/header.jsp" />

	<div class="main_wrap1">
	<div class="main_all">
	<!--左边tab-->
		<div class="left_main">
		  <jsp:include page="/common/menu.jsp" />
		</div>
		<!--左边tab结束-->
		
		<!--右边-->
		<div class="right_box">
		<form id="inputForm" action="${ctx}/cus/draft!save.action" method="post" >
			<input type="hidden" name="draft.id" value="${draft.id}"/>
			<div class="top_serach_box">
                <input type="hidden" name="" />
                <ul class="form" id="orderFields">
		        	<li><label><spring:message code="order.biz_type" /></label><select class="jsdroplist" name="draft.biztype" id="biz_type" parent="none" onchange="reloadSon('flow_type',this.value)" son="flow_type" init="${draft.biztype}" action="${ctx}/droplist!buscat.action"></select></li>
				    <li><label><spring:message code="order.flow_type" /></label><select class="jsdroplist" name="flowTypeId" id="flow_type" parent="biz_type" init="${flowTypeId}" action="${ctx}/droplist!flowtype.action"></select></li>
				    <li><label><spring:message code="order.customer_code" /></label><input id="cusCodeAuto"  name="draft.cusCode" value="${draft.cusCode}" type="text" size="45" class="required"/></li>
				    <li><label><spring:message code="order.customer_name" /></label><input id="cusNameAuto" name="draft.cusName" value="${draft.cusName}" type="text" size="45"/></li>
				    <li class="optionField type1 type2"><label><spring:message code="order.big_code" /></label><input name="draft.bigCode" value="${draft.bigCode}" type="text" size="15"/></li>
				    <li class="optionField type1 type2"><label><spring:message code="order.small_code" /></label><input name="draft.smallCode" value="${draft.smallCode}" type="text" size="15"/></li>
				    <li class="optionField type1"><label><spring:message code="order.import_code" /></label><input name="draft.importCode" value="${draft.importCode}" type="text" size="15"/></li>
				    <li><label><spring:message code="order.goods_name" /></label><input name="draft.goods" value="${draft.goods}" type="text" size="15"/></li>
				    <li class="optionField type4 type3 dn"><label><spring:message code="order.pick_up" /></label><input name="draft.pickUpAddr" value="${draft.pickUpAddr}" type="text" size="45"/></li>
				    <li class="optionField type4 type3 dn"><label><spring:message code="order.destination" /></label><input name="draft.destination" value="${draft.destination}" type="text" size="45"/></li>
			    </ul>
				<p class="button_box"><input type="submit" value="保   存"/>&nbsp;&nbsp;
				<input type="button" value="取  消" onclick="javascript:history.back();"/>
				</p>
			</div>
		</form>
		</div>
		<!--右边结束-->
		
		</div> 
	<jsp:include page="/common/footer.jsp" />
</div>
</body>
</html>

